package com.example.hxds.dr.service.impl;

import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.example.hxds.dr.db.dao.DriverSettingsDao;
import com.example.hxds.dr.service.DriverSettingsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @BelongsProject: hxds
 * @BelongsPackage: com.example.hxds.dr.service.impl
 * @Author: wanglansheng
 * @CreateTime: 2024-01-14  11:02
 * @Description: TODO
 * @Version: 1.0
 */
@Service
public class DriverSettingsServiceImpl implements DriverSettingsService {
    @Resource
    private DriverSettingsDao driverSettingsDao;
    @Override
    public HashMap searchDriverSettings(long driverId) {
        String settings = driverSettingsDao.searchDriverSettings(driverId);
        HashMap map = JSONUtil.parseObj(settings).toBean(HashMap.class);
        boolean bool = MapUtil.getInt(map, "listenService") == 1 ? true : false;
        map.replace("listenService", bool);
        bool = MapUtil.getInt(map, "autoAccept") == 1 ? true : false;
        map.replace("autoAccept", bool);
        return map;
    }
}
